package cn.doitedu

import org.apache.spark.sql.SparkSession

object TestUdafNon {

  def main(args: Array[String]): Unit = {
    val spark = SparkSession.builder()
      .appName("")
      .master("local[*]")
      .getOrCreate()

    val df = spark.read.option("header", "true").csv("spark_teach/data/bitmap/input").selectExpr("cast(guid as int)", "province", "city", "region")
    df.createTempView("df")

    spark.udf.register("non",TestUdaf)


    spark.sql(
      """
        |select
        |province,
        |non(guid) as non_id
        |from df
        |group by province
        |
        |""".stripMargin).explain()

    spark.close()
  }

}
